package com.ruoyi.business.seaTotal.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.domain.entity.SysUser;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.seaTotal.domain.SeaTotalData;
import com.ruoyi.business.seaTotal.service.ISeaTotalDataService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;

/**
 * 海洋数据总览Controller
 * 
 * @author ruoyi
 * @date 2024-10-31
 */
@RestController
@RequestMapping("/seaTotal/seaData")
public class SeaTotalDataController extends BaseController
{
    @Autowired
    private ISeaTotalDataService seaTotalDataService;

    /**
     * 查询海洋数据总览列表
     */
    @PreAuthorize("@ss.hasPermi('seaTotal:seaData:list')")
    @GetMapping("/list")
    public TableDataInfo list(SeaTotalData seaTotalData)
    {
        startPage();
        List<SeaTotalData> list = seaTotalDataService.selectSeaTotalDataList(seaTotalData);
        return getDataTable(list);
    }

    @GetMapping("/windChartlist")
    public List<SeaTotalData> windChartlist(SeaTotalData seaTotalData)
    {
        startPage();
        List<SeaTotalData> list = seaTotalDataService.selectSeaTotalDataList(seaTotalData);
        return null;
    }



    /**
     * 导出海洋数据总览列表
     */
    @PreAuthorize("@ss.hasPermi('seaTotal:seaData:export')")
    @Log(title = "海洋数据总览", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SeaTotalData seaTotalData)
    {
        List<SeaTotalData> list = seaTotalDataService.selectSeaTotalDataList(seaTotalData);
        ExcelUtil<SeaTotalData> util = new ExcelUtil<SeaTotalData>(SeaTotalData.class);
        util.exportExcel(response, list, "海洋数据总览数据");
    }

    /**
     * 获取海洋数据总览详细信息
     */
    @PreAuthorize("@ss.hasPermi('seaTotal:seaData:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(seaTotalDataService.selectSeaTotalDataById(id));
    }

    /**
     * 新增海洋数据总览
     */
    @PreAuthorize("@ss.hasPermi('seaTotal:seaData:add')")
    @Log(title = "海洋数据总览", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SeaTotalData seaTotalData)
    {
        return toAjax(seaTotalDataService.insertSeaTotalData(seaTotalData));
    }

    /**
     * 修改海洋数据总览
     */
    @PreAuthorize("@ss.hasPermi('seaTotal:seaData:edit')")
    @Log(title = "海洋数据总览", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SeaTotalData seaTotalData)
    {
        return toAjax(seaTotalDataService.updateSeaTotalData(seaTotalData));
    }

    /**
     * 删除海洋数据总览
     */
    @PreAuthorize("@ss.hasPermi('seaTotal:seaData:remove')")
    @Log(title = "海洋数据总览", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(seaTotalDataService.deleteSeaTotalDataByIds(ids));
    }

    @PostMapping("/importTemplate")
    public void importTemplate(HttpServletResponse response)
    {
        ExcelUtil<SeaTotalData> util = new ExcelUtil<>(SeaTotalData.class);
        util.importTemplateExcel(response, "海洋数据");
    }

    @Log(title = "用户管理", businessType = BusinessType.IMPORT)
    @PostMapping("/importData")
    public AjaxResult importData(MultipartFile file) throws Exception
    {
        ExcelUtil<SeaTotalData> util = new ExcelUtil<>(SeaTotalData.class);
        List<SeaTotalData> seaTotalDataList = util.importExcel(file.getInputStream());
        String message = seaTotalDataService.importSeaTotalData(seaTotalDataList);
        return success(message);
    }
}
